<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/vue.js"></script>
    <style>
        *{
            padding:0;
            margin:0;
        }
        button{
            padding:5px;
            margin:5px;
        }
        button.active{
            background:red;
        }
        #root div{
            width:500px;
            height: 200px;
            border:1px solid green;
        }
    </style>
</head>
<body>
<div id="root">
    <button @click="id=item.id;" :class="{active:id===item.id}" v-for="item in info" :key="item.id">{{item.type}}</button>
    <div>
        <p v-for="item in newsList" :key="item.id">{{item.title}}</p>
    </div>
</div>
</body>
<script>
	new Vue({
		el:"#root",
        data:{
			id:1,
            newsList:[],
			info:[
				{
					id:1,
					type:"体育",
                    newsList:[
						{
							id:11,
                            title:"体育新闻1"
                        },
						{
							id:12,
							title:"体育新闻2"
						}
                    ]
                },
				{
					id:2,
					type:"娱乐",
					newsList:[
						{
							id:21,
							title:"娱乐新闻1"
						},
						{
							id:22,
							title:"娱乐新闻2"
						}
					]
				},
				{
					id:3,
					type:"财经",
					newsList:[
						{
							id:31,
							title:"财经新闻1"
						},
						{
							id:32,
							title:"财经新闻2"
						}
					]
				}
            ]
        },
        // beforeMount(){
		//     this.newsList = this.info.find(v=>v.id === this.id).newsList
        // },
        watch:{
			id:{
				handler(){
					this.newsList = this.info.find(v=>v.id === this.id).newsList;
                },
                immediate:true
            }
        }
	})
</script>
</html>